This program modual contains the Initializing and Modification code to
colorize the windows and scroll bars.
*/
void set_color(aWindow) /* When a new window has been created, I'll initialize
the new window's colors to these default values, change
them as you see fit. See Inside Macintosh Vol 5, page 202,
The Window Color Tables paragraph for a detailed explaination
of what is going on here. Each window should get its own
unique Color Table.
*/
CWindowPtr aWindow;
{
CWindowPeek peek;
ControlHandle control;
CTabHandle new_color_handle;
GetPort(&savedPort); /* Save the Graf Port */
/*
in order to display a window in color, I must first create a color table that
will contain color definitions for all the parts of the window. Each window
should have its own unique color table. If we don't give each window a
unique color table, then color changes in one window will affect all
the windows. Read Inside Mac Vol. 5, page V-48 for a definition of the color
table record. Page V-134 contains even more info on color tables and on how
the color manager works and utilizes a color table.
*/
/* First get some RAM to store the Window's ColorTable in. A window has five
parts that can be colored.
I will need RAM for the Color table and RAM for the 5 color specs necessary
to hold the color info for each of the window parts */
new_color_handle = (CTabHandle)NewHandle(sizeof(ColorTable) + (5 * sizeof(ColorSpec))); /* allocate a new color Table for this Window */
if(!new_color_handle) /* check the handle to be certain that the Mac OS actually gave me some RAM */
{ SysBeep(10); return; } /* no memory can be allocated for this color table */
/* Now initialize the ColorTable to these values to start with, don't worry, I
just made the RGB numbers up, they have no special significance.
Page V-202 of Inside Macintosh gives detailed info on the definitions
of the fields and the values they can take on
*/
(*new_color_handle)->ctSize = 4; /* This is the Color Table Size parameter, there are 5 parts to a window that can be colored, they are numbered 0 thru 4 */
(*new_color_handle)->ctTable[0].value = wContentColor; /* The "value" fields in
the color table tell
the Color manager which
part of the window this
color definition record
is for. I hope you know
what the content region
of a window is */
(*new_color_handle)->ctTable[0].rgb.red = 0;
(*new_color_handle)->ctTable[0].rgb.green = 56;
(*new_color_handle)->ctTable[0].rgb.blue = 56789;
(*new_color_handle)->ctTable[1].value = wFrameColor; /* define the Window Frame color */
(*new_color_handle)->ctTable[1].rgb.red = 0;
(*new_color_handle)->ctTable[1].rgb.green = 6789;
(*new_color_handle)->ctTable[1].rgb.blue = 20000;
(*new_color_handle)->ctTable[2].value = wTextColor; /* this is for the text in the title bar, not the text edit text */